livepatch: Do not enforce ELF_LIVEPATCH_FUNC section presence
authorPawel Wieczorkiewicz <wipawel@amazon.de>
Tue, 26 Nov 2019 10:07:55 +0000 (10:07 +0000)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 13 Dec 2019 14:45:32 +0000 (14:45 +0000)
commit76b3d4098a92a323a43bc250c67c721c1eed0acb
tree06d76298ccdbfe0b04da7670a5c0726afb115a08
parentef87efee9d38b61624f25c1a056d386a70ba99aa
livepatch: Do not enforce ELF_LIVEPATCH_FUNC section presence

With default implementation the ELF_LIVEPATCH_FUNC section containing
all functions to be replaced or added must be part of the livepatch
payload, otherwise the payload is rejected (with -EINVAL).

However, with the extended hooks implementation, a livepatch may be
constructed of only hooks to perform certain actions without any code
to be added or replaced.
Therefore, do not always expect the functions section and allow it to
be missing, provided there is at least one section containing hooks
present. The functions section, when present in a payload, must be a
single, non-empty section.

Check also all extended hooks sections if they are a single, non-empty
sections each.

At least one of the functions or hooks section must be present in a
valid payload.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Martin Pohlack <mpohlack@amazon.de>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
xen/common/livepatch.c
xen/include/xen/livepatch.h
xen/test/livepatch/Makefile
xen/test/livepatch/xen_action_hooks_nofunc.c [new file with mode: 0644]